package br.edu.unilasalle.simon_api.dao.impl;

import java.util.List;

import javax.persistence.TypedQuery;

import org.springframework.stereotype.Repository;

import br.edu.unilasalle.simon_api.dao.IFornecedorDao;
import br.edu.unilasalle.simon_api.domain.Fornecedor;

@Repository
public class FornecedorDao extends GenericDao<Fornecedor, Long> implements IFornecedorDao {
	
	public List<Fornecedor> findAllFornecedor() {
        StringBuilder str = new StringBuilder();
        str.append("select new Fornecedor(o.id, o.empresa, o.cnpj, o.contato, o.fone1, o.ativo) from Fornecedor o ");
        str.append("order by o.empresa, o.cnpj");
        TypedQuery<Fornecedor> q = entityManager.createQuery(str.toString(), Fornecedor.class);
		return q.getResultList();
    }
	
}
